package com.captain.lc.数组;

/**
 * Des:
 *
 * @author XL
 * @Date 2021/12/7 8:44
 */
public class 移动零 {

    public static void main(String[] args) {
        new 移动零().moveZeroes(new int[]{0,1,0,3,12});


    }
    public void moveZeroes(int[] nums) {
        //快慢指针
        if (nums == null || nums.length == 0) {
            return;
        }
        int left = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) {
                continue;
            }
            int tp = nums[i];
            nums[i] = nums[left];
            nums[left] = tp;
            left++;
        }
        for (int num : nums) {
            System.out.println(num);
        }
    }
}
